package com.alpha.schema.beans;

import lombok.Data;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

/**
 * 元数据定义
 *
 * @author chenruwan
 * @since 2022-01-01
 */
@Data
@Accessors(chain = true)
public class Schema {
    String packageName;
    Boolean reactive;
    List<Choice> choices = new ArrayList<>();
    List<Table> tables = new ArrayList<>();

    public Table findTable(String tableName) {
        for (Table table : getTables()) {
            if (table.getName().equals(tableName)) {
                return table;
            }
        }

        throw new IllegalArgumentException("Can Not Find Table : " + tableName);
    }
}
